package com.ygk.bluepath.member.Presenter;

import com.ygk.bluepath.core.BPresenter;
import com.ygk.bluepath.member.Model.LoginModel;
import com.ygk.bluepath.member.View.LoginActivity;
import com.ygk.bluepath.member.View.LoginView;

import org.json.JSONObject;

/**
 * Created by USER on 2016/7/8.
 */
public class LoginPresenter extends BPresenter {

    private LoginView mLoginView;
    private LoginModel mLoginModel;

    public LoginPresenter(LoginActivity mActivity,LoginView mView) {
        super(mActivity,mView);
        this.mLoginView = mView;
        this.mLoginModel = new LoginModel(this);
        setModel(mLoginModel);
    }


    @Override
    public void dealJsonObject(JSONObject result, String oid, Object extraStr) {
        super.dealJsonObject(result, oid, extraStr);
        if (result!=null){
            String msg=result.optString("msg");
            tt(msg);
            int code=result.optInt("code");
            if (code==0){
                JSONObject jsonData=result.optJSONObject("data");
                if (jsonData!=null){
                    String token=jsonData.optString("token");
                    sp.setToken(token);
                    tt("Token:"+token);
                }
            }

        }

    }

}
